const infoData={
    list:[],
    active:0,
    listChildren:[]
}

const reducer = (state= infoData,{type,payload}) =>{
    let newState = JSON.parse(JSON.stringify(state))

    switch (type) {
        
        case "GET_LIST":
            newState.list = payload
            newState.listChildren = payload[0].children
            return newState

        case "SET_ACTIVE":
            newState.active = payload
            return newState

        case "SET_LISTCHILDREN":
            newState.listChildren = newState.list[payload].children
            return newState
            
        default:
            return newState
    }
}

export default reducer